home *** CD-ROM | disk | FTP | other *** search
/ HyperLib 1997 Winter - Disc 1 / HYPERLIB-1997-Winter-CD1.ISO.7z / HYPERLIB-1997-Winter-CD1.ISO / オンラインウェア / PRG / MacPerl 506 appl folder.sit / MacPerl 506 appl folder / Mac_Perl_506r1m_appl / lib / CommConnect.pl < prev    next >
Text File  |  1994-10-05  |  2KB  |  141 lines

  1. #
  2. # CommConnect -- Perl embedding of Alex Metcalf's CommConnect XFCN
  3. #
  4. # Authors: XFCN          Alex Metcalf <alex@metcalf.demon.co.uk>
  5. #          Perl Wrapper  Matthias Neeracher <neeri@iis.ee.ethz.ch>
  6. #
  7. # The CommConnect XFCN is ShareWare! Please refer to the HyperCard
  8. # stack you should have received with this file for details.
  9. #
  10.  
  11. package CommConnect;
  12.  
  13. &MacPerl'LoadExternals("CommConnect.pl");
  14.  
  15. #
  16. # $status = &CommConnect'Prepare([Tool])
  17. #
  18. # Prepare a connection tool (default is first in extensions folder)
  19. # for use.
  20. #
  21.  
  22. sub Prepare {
  23.    local($tool) = @_;
  24.  
  25.    if ($tool) {
  26.       &CommConnect("prepare for use", $tool);
  27.    } else {
  28.       &CommConnect("prepare for use");
  29.    }
  30. }
  31.  
  32. #
  33. # $status = &CommConnect'Choose([X,Y])
  34. #
  35. # Show dialog box to select tool and settings.
  36. #
  37.  
  38. sub Choose {
  39.    local($x, $y) = @_;
  40.  
  41.    if ($x) {
  42.       &CommConnect("choose connection", "$x, $y");
  43.    } else {
  44.       &CommConnect("choose connection");
  45.    }
  46. }
  47.  
  48. #
  49. # $settings = &CommConnect'GetSettings()
  50. #
  51. # Get current tool settings.
  52. #
  53.  
  54. sub GetSettings {
  55.    &CommConnect("get connection settings");
  56. }
  57.  
  58. #
  59. # $status = &CommConnect'ChangeSettings($settings)
  60. #
  61. # Change current tool settings.
  62. #
  63.  
  64. sub ChangeSettings {
  65.    local ($settings) = @_;
  66.    &CommConnect("change connection settings", $settings);
  67. }
  68.  
  69. #
  70. # $status = &CommConnect'Cleanup()
  71. #
  72. # Clean up after using a tool.
  73. #
  74.  
  75. sub Cleanup {
  76.    &CommConnect("end of use");
  77. }
  78.  
  79. #
  80. # $status = &CommConnect'OpenConnection()
  81. #
  82. # Open a connection with the chosen tool.
  83. #
  84.  
  85. sub OpenConnection {
  86.    &CommConnect("open connection");
  87. }
  88.  
  89. #
  90. # $status = &CommConnect'CloseConnection()
  91. #
  92. # Open a connection with the chosen tool.
  93. #
  94.  
  95. sub CloseConnection {
  96.    &CommConnect("close connection");
  97. }
  98.  
  99. #
  100. # $status = &CommConnect'Idle()
  101. #
  102. # Perform periodical tasks. Call occasionally.
  103. #
  104.  
  105. sub Idle {
  106.    &CommConnect("idle");
  107. }
  108.  
  109. #
  110. # $status = &CommConnect'Send($data)
  111. #
  112. # Send Data.
  113. #
  114.  
  115. sub Send {
  116.    local($data) = @_;
  117.    
  118.    while (length($data)) {
  119.       if ($data =~ /^¥0/) {
  120.          &CommConnect("send null");
  121.          $data = $';
  122.       } elsif ($data =~ /^[¥1-¥377]+/) {
  123.          &CommConnect("send", $&);
  124.          $data = $';
  125.       }
  126.    }
  127. }
  128.  
  129. #
  130. # $data = &CommConnect'Receive()
  131. #
  132. # Receive Data.
  133. #
  134.  
  135. sub Receive {
  136.    &CommConnect("receive");
  137. }
  138.  
  139. 1;
  140.  
  141.